package org.sbbs.utils.webapp.action;

import java.util.List;

import org.hibernate.Session;
import org.sbbs.base.dao.GeneralDao;
import org.sbbs.base.webapp.action.BaseGridAction;
import org.sbbs.base.webapp.search.ComboGridPageReqParameters;
import org.sbbs.base.webapp.search.PropertySearchBuilder;
import org.sbbs.security.service.UserManager;
import org.sbbs.utils.service.impl.ComboGridManager;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;

public class CombogridAction extends BaseGridAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String gridPageList() {

		Search search = PropertySearchBuilder.BuildSearch(getRequest(), new ComboGridPageReqParameters());
		if (this.searchTerm != null) {
			search.addFilterLike("username", "%" + this.searchTerm + "%");
		}
		SearchResult srt = this.userManager.searchAndCount(search);
		this.preGridPageResult(search, srt);
		this.rows = this.pageList;
		return this.ajaxReturn.success("load success,dwz message test.");
	}

	public String commonSqlPageList() {
		Search search = PropertySearchBuilder.BuildSearch(getRequest(), new ComboGridPageReqParameters());
		if (this.searchTerm != null) {
			this.searchTerm = "%" + this.searchTerm + "%";
		} else {
			this.searchTerm = "%%";
		}
		SearchResult srt = this.comboGridManager.commonSqlComboGrid(qlSrc, searchTerm, search);
		this.preGridPageResult(search, srt);
		this.rows = this.pageList;
		return this.ajaxReturn.success("load success,dwz message test.");

	}

	public String commonHqlPageList() {

		// this.generalDao.s

		return this.ajaxReturn.success("load success,dwz message test.");
	}

	private String qlType;
	private String qlSrc;
	private String searchTerm;
	private List rows;
	private UserManager userManager;
	private ComboGridManager comboGridManager;

	public List getRows() {
		return rows;
	}

	public String getSearchTerm() {
		return searchTerm;
	}

	public void setQlSrc(String QlSrc) {
		this.qlSrc = QlSrc;
	}

	public void setQlType(String qlType) {
		this.qlType = qlType;
	}

	public void setSearchTerm(String searchTerm) {
		this.searchTerm = searchTerm;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

	public void setComboGridManager(ComboGridManager ComboGridManager) {
		this.comboGridManager = ComboGridManager;
	}

}
